package com.xggstudio.crm.ui.mvp.v;

import android.util.Log;
import android.view.View;
import android.widget.TextView;

import com.xggstudio.crm.R;
import com.xggstudio.crm.base.App;
import com.xggstudio.crm.base.BaseFragment;
import com.xggstudio.crm.ui.mvp.m.LoginBean;
import com.xggstudio.crm.ui.mvp.m.UserInfoBean;
import com.xggstudio.crm.ui.mvp.p.P_myself;

public class MySelfFragment extends BaseFragment implements View.OnClickListener ,IMyself {

    private TextView user;

    private TextView other;

    private TextView name;

    private P_myself pMyself;

    @Override
    protected int getLayout() {
        return R.layout.fragment_myself;
    }

    @Override
    protected void init(View v) {
        initView();
    }

    private void initView(){

        user = (TextView) $(R.id.user);
        other = (TextView) $(R.id.other);
        name = (TextView) $(R.id.name);

        user.setOnClickListener(this);
        other.setOnClickListener(this);

        LoginBean token = App.getInstance().getLoginBean();

        pMyself = new P_myself(this);
        pMyself.getInfo(token.getResult().getAccess_token());
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.user:
                startToActivity(UserListActivity.class);
                break;

            case R.id.other:
                startToActivity(OtherListActivity.class);
                break;
        }
    }

    @Override
    public void setViewData(UserInfoBean info) {
        name.setText(info.getResult().getName());
    }
}
